# -*- coding: utf-8 -*-
import itertools
import subprocess
import random

def do_build_bat(sample):    
    newdata = """
    SET CL=/DHOCS_A#%s /DHOCS_B#%s /DHOCS_NB#%s /DHOCS_NSC#%s

    echo %CL%

    devenv ml_leaves\\ML_Leaves\\ML_Leaves.sln /Clean
    devenv ml_leaves\\ML_Leaves\\ML_Leaves.sln /build "Release"

    ml_leaves\ML_Leaves\Release\training.exe
    ml_leaves\ML_Leaves\Release\testing.exe""" %(sample[0],sample[1], sample[2], sample[3])

    with open('build.bat','w') as f:
        f.write(newdata)


A = range(7,8)
B = range(0,5)
NB = range(21,25)
NSCALES = range(15,30,5)

combinations = set([x for x in itertools.product(A,B,NB,NSCALES)])

for i in range(1,len(A)*len(B)*len(NB)*len(NSCALES)):
    sample = random.choice(list(combinations))
    combinations = combinations - set([sample])
    
    do_build_bat(sample)
    
    subprocess.call(['build.bat', str(sample[0]), str(sample[1]), str(sample[2]), str(sample[3])])